class Solution
{
public:
    int cuttingBamboo(int n)
    {
        if (n <= 3) return n - 1;
        long long ans = 1;
        if (n % 3 == 1)
        {
            ans = 4;
            n = n - 4;
        }
        if (n % 3 == 2)
        {
            ans = 2;
            n = n - 2;
        }
        while (n)
        {
            ans = ans * 3 % 1000000007;
            n = n - 3;
        }
        return (int)ans;
    }
};